%Calculates the saturation of Image by calculating the standard deviation
%between the Red, Green and Blue channels
function [S] = saturation2(Image)
RGB = double(Image);
rows = size(RGB,1);         %# rows
cols = size(RGB,2);         %# cols    
avg = zeros(rows,cols);     % placeholder
sigma = zeros(rows,cols);   % placeholder for stan.dev. 
for row = 1:rows
    for col = 1:cols
        avg(row,col) = mean(RGB(row,col,:));
        sum = 0;
        for chan = 1:3
            sum = sum + (RGB(row,col,chan) - avg(row,col))^2;
        end
        sigma(row,col) = sqrt(sum/3);    %standard deviation;
    end
end

S = sigma;

